import { S } from '../../s';
import { PSEditorImpl } from '../pseditor-impl';
import { IPSArray } from './ipsarray';
import { IPSSysValueRule } from '../../valuerule/ipssys-value-rule';

export class PSArrayImpl extends PSEditorImpl implements IPSArray {
  get dataType(): string {
    return this.M.dataType || 'STRING';
  }

  get maxLength(): number {
    return this.M.maxLength;
  }

  get maxValue(): number {
    return this.M.maxValue;
  }

  get minLength(): number {
    return this.M.minLength != null ? this.M.minLength : 0;
  }

  get minValue(): number {
    return this.M.minValue;
  }

  protected pssysvaluerule: IPSSysValueRule;
  getPSSysValueRule(): IPSSysValueRule | null {
    return (
      this.pssysvaluerule ||
      (this.pssysvaluerule = this.fillObjectModel(
        S._1b,
        this.M.getPSSysValueRule,
        S._2f3,
      ) as IPSSysValueRule)
    );
  }

  get precision(): number {
    return this.M.precision;
  }

  get showMaxLength(): boolean {
    return this.M.showMaxLength != null ? this.M.showMaxLength : false;
  }
  get cls(): string {
    return 'PSArrayImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._3e0 || cls == S._139 || cls == S._13f) return true;
    return super.instanceof(cls);
  }
}
